package cn.itsource.hrm.dto;

import cn.itsource.hrm.domain.Employee;
import cn.itsource.hrm.domain.Tenant;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * Springmvc给我们提供常用的校验，是一个规范 Bean Validation 1.0 (JSR 303)
 * //1基础用法
 * //1)打注解 javax.validation.constraints包下面的一些注解
 * //2)校验  entering(@RequestBody @Valid TenantEnteringDto dto){
 * //2 高级用法
 * 1)定制信息注解(mesage="xxx")
 * 2)全局参数异常处理
 *   (@RequestBody @Valid TenantEnteringDto dto, BindingResult result){ 当个处理
 *   //处理参数校验异常
     @ExceptionHandler(MethodArgumentNotValidException.class)//处理GlobalException
 * 3 自定义注解 自己搞-不会用
 *
 */
public class TenantEnteringDto {
//    @NotNull
    @Valid
    private Tenant tenant;
//    @NotNull
    @Valid
    private Employee employee;

    //如果报错了，有默认错误提示信息（javax.validation.constraints.注解名.message）
    @NotNull(message="套餐不能为null!")
    private Long mealId;
    @NotEmpty(message = "确认密码不能为Empty！")
    private String comfirmPwd;


    public Tenant getTenant() {
        return tenant;
    }

    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }

    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    public Long getMealId() {
        return mealId;
    }

    public void setMealId(Long mealId) {
        this.mealId = mealId;
    }

    public String getComfirmPwd() {
        return comfirmPwd;
    }

    public void setComfirmPwd(String comfirmPwd) {
        this.comfirmPwd = comfirmPwd;
    }

    @Override
    public String toString() {
        return "TenantEnteringDto{" +
                "tenant=" + tenant +
                ", employee=" + employee +
                ", mealId=" + mealId +
                ", comfirmPwd='" + comfirmPwd + '\'' +
                '}';
    }
}
